package com.example.myimg;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URL;

//http://glapi.cn/pic/mm.php
public class MyImgView {
    public static void main(String[] args) throws IOException
    {
        System.out.println(geturl("http://fenchingking.top/photoApi/api"));
    }
    public static String geturl(String api) throws IOException
    {
                    URL url = new URL(api);
                    //打开到此 URL 的连接并返回一个用于从该连接读入的 InputStream。
                    Reader reader = new InputStreamReader(new BufferedInputStream(url.openStream()));
                    int c;
                    String x="";
                    while ((c = reader.read()) != -1) {
                        x+=(char)c;
                    }
                    reader.close();

                return x;
    }
}